/*
 *  CEEditBox.h
 *  LID Library
 *
 *  Created by Alexander Trutchenko on 09/11/11.
 *  Copyright 2011 League of Independent Developers. All rights reserved.
 *
 */

#ifndef __CE_EditBox_h__
#define __CE_EditBox_h__

#include "cocos2dx_extentions/nodes/CENodeScissored.h"

#include "cocos2d.h"

#include <string>

namespace cocosext {

class CELabelBMFont;

/////////////////////////////////////////////////////
//
/** CEEditBox 
* 
*/
/////////////////////////////////////////////////////

typedef enum
{
	eSEEditBoxStateNormal = 0,
	eSEEditBoxStatePressed,
	eSEEditBoxStateDisabled,
} ECEEditBoxState;

class CEEditBox : public cocos2d::CCNode
{
protected:

	//Frame and scrollable area
	CELabelBMFont* _scrollableArea;
	CENodeScissored<cocos2d::CCNode>* _frame;

	std::string _font;
	float _fontScale;
	cocos2d::ccColor3B _textColor;

	//Bk
	cocos2d::CCSprite* _normalLeft;
	cocos2d::CCSprite* _normalCenter;
	cocos2d::CCSprite* _normalRight;
	cocos2d::CCSprite* _pressedLeft;
	cocos2d::CCSprite* _pressedCenter;
	cocos2d::CCSprite* _pressedRight;
	cocos2d::CCSprite* _disabledLeft;
	cocos2d::CCSprite* _disabledCenter;
	cocos2d::CCSprite* _disabledRight;

	float _centerScaleX;
	ECEEditBoxState _state;

protected:
	CEEditBox(const char* font,
		      float fontScale,
			  cocos2d::ccColor3B textColor,
			  cocos2d::CCSprite* normalLeft,
			  cocos2d::CCSprite* normalCenter,
			  cocos2d::CCSprite* normalRight,
			  cocos2d::CCSprite* pressedLeft,
			  cocos2d::CCSprite* pressedCenter,
			  cocos2d::CCSprite* pressedRight,
			  cocos2d::CCSprite* disabledLeft,
			  cocos2d::CCSprite* disabledCenter,
			  cocos2d::CCSprite* disabledRight)
		: _scrollableArea(NULL)
		, _frame(NULL)
		, _font(font)
		, _fontScale(fontScale)
		, _textColor(textColor)
		, _normalLeft(normalLeft)
		, _normalCenter(normalCenter)
		, _normalRight(normalRight)
		, _pressedLeft(pressedLeft)
		, _pressedCenter(pressedCenter)
		, _pressedRight(pressedRight)
		, _disabledLeft(disabledLeft)
		, _disabledCenter(disabledCenter)
		, _disabledRight(disabledRight)
	    , _centerScaleX(1.f)
	    , _state(eSEEditBoxStateNormal){;}

	virtual bool init();


public:
    virtual ~CEEditBox() {;}

	static CEEditBox* node(const char* font,
						   float fontScale,
						   cocos2d::ccColor3B textColor,
						   cocos2d::CCSprite* normalLeft,
						   cocos2d::CCSprite* normalCenter,
						   cocos2d::CCSprite* normalRight,
						   cocos2d::CCSprite* pressedLeft,
						   cocos2d::CCSprite* pressedCenter,
						   cocos2d::CCSprite* pressedRight,
						   cocos2d::CCSprite* disabledLeft,
						   cocos2d::CCSprite* disabledCenter,
						   cocos2d::CCSprite* disabledRight);

public:
	void setText(const wchar_t* text);

//Cocos2d interface
	virtual void setContentSize(const cocos2d::CCSize& contentSize);

}; //CEEditBox


}; // end namespace cocosext

#endif // __CE_EditBox_h__
